﻿using Newtonsoft.Json;
using System.ComponentModel;

namespace Library.Common.Model
{
    /// <summary>
    /// 返回给客户端的信息实体
    /// </summary>
    public class BaseApiResult<T>
    {
        /// <summary>
        /// 返回客户端数据
        /// </summary>
        [Description("返回客户端数据")]
        public T Data { get; set; } = default(T);

        /// <summary>
        /// 额外信息
        /// </summary>
        [Description("额外信息")]
        public string ExtraInfo { get; set; } = string.Empty;

        /// <summary>
        /// 接口内部处理 返回码
        /// </summary>
        [Description("接口内部处理 返回码")]
        public int Code { get; set; } = (int)CustomError.Success;

        /// <summary>
        /// 请求接口成功/失败 
        /// </summary>
        [Description("请求接口成功/失败 ")]
        public bool Success { get; set; } = true;

        /// <summary>
        /// 返回的操作消息
        /// </summary>
        [Description("返回的操作消息")]
        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]//空值的处理
        public string Msg { get; set; } = "操作成功";

        /// <summary>
        /// 异常信息
        /// </summary>
        public string ErrMessage { get; set; } = string.Empty;
    }
}
